<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>reduce map 迭代器，有什么不同 ①.实现函数：同时使⽤ reduce map 迭代器，让数组内所有的 偶数求和 ②.实现函数：只使⽤ reduce 求奇数之和</title>
</head>

<body>

</body>
<script>
  let arr = [1999, 1, 9, 3, 4, 5, 6, 7]
  // arr.reduce((prev, cur) => {
  //   console.log(prev, cur);
  //   return prev
  // })

  let sum = arr.reduce((a, b) => {
    if (b % 2 == 0) {
      return a + b
    }
    return a + 0
  }, 0)
  console.log(sum);
</script>

</html>